package com.lagou.dubbo.service.impl;

import com.lagou.dubbo.DubboService;
import org.apache.dubbo.config.annotation.Service;

import java.util.Random;
import java.util.concurrent.TimeUnit;

@Service
public class DubboServiceImpl implements DubboService {


    @Override
    public void insert() {
        sleep();
        System.out.println("调用insert");
    }

    @Override
    public void delete() {
        sleep();
        System.out.println("调用delete");
    }

    @Override
    public void update() {
        sleep();
        System.out.println("调用update");
    }


    private void sleep(){
        int random = new Random().nextInt(100)+1;
        try {
            TimeUnit.MILLISECONDS.sleep(random);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }

}
